package com.cloudsigns.factorymanager2.produce.presenter;

import android.os.Handler;

import com.cloudsigns.factorymanager2.produce.bean.ProduceProduceOrderBean;
import com.cloudsigns.factorymanager2.produce.iview.IGetProductOrderListView;
import com.cloudsigns.factorymanager2.produce.model.GetProductOrderListModel;
import com.cloudsigns.factorymanager2.produce.model.IGetProductOrderListModel;

import java.util.List;


public class GetProductOrderListPresenter {
    private IGetProductOrderListView view;
    private IGetProductOrderListModel model;
    private Handler mHandler = new Handler();

    public GetProductOrderListPresenter(IGetProductOrderListView iView) {
        this.view = iView;
        this.model = new GetProductOrderListModel();
    }

    public void getProductOrderList() {
        model.getReceiveEngineeringOrderList(new GetProductOrderListModel.OnGetProductOrderListListener() {
            @Override
            public void getDataSuccessed(final List<ProduceProduceOrderBean> orderParentBeanList,
                                         final List<ProduceProduceOrderBean> productBeanList_status_send,
                                         final List<ProduceProduceOrderBean> productBeanList_status_receives,
                                         final List<ProduceProduceOrderBean> productBeanList_status_returns,
                                         final List<ProduceProduceOrderBean> productBeanList_status_success) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.showData(orderParentBeanList, productBeanList_status_send, productBeanList_status_receives, productBeanList_status_returns, productBeanList_status_success);
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void getDataFailed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.showFailedError(desc);
                        view.hideLoading();
                    }
                });
            }
        });
    }
}
